$(document).ready(function () {
  /* form init validation */
  var form = $("#sodetailsForm");
  
	$("#materialId").select2({
		ajax : {
			url : rootUrl + "/api/master/materials",
		}
	});
  // JQuery validate 插件看文档
  // form validation
  form.validate({
    rules: {
      no: {
        remote: baseUrl + "/check/no?oldNo=" + oldNo,
        alnum: true,
        maxlength: 4
      },
      name: {
        remote: baseUrl + "/check/name?oldName=" + oldName,
        maxlength: 128
      }
    },
    messages: {
      no: {
        remote: "该发运订单明细编号已被使用!"
      },
      name: {
        remote: "该发运订单中文名称已经被使用!"
      }
    }
  });
});
